package com.plugin.wxapp.rest;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mybatisplus.main.common.RedisUtil;
import com.mybatisplus.main.common.Result;
import com.plugin.wxapp.entity.MonsterModule;
import com.plugin.wxapp.entity.MonsterModuleImg;
import com.plugin.wxapp.entity.MonsterUser;
import com.plugin.wxapp.entity.UserInfo;
import com.plugin.wxapp.service.MonsterModuleImgService;
import com.plugin.wxapp.service.MonsterModuleService;
import com.plugin.wxapp.service.MonsterUserService;
import com.plugin.wxapp.util.CommonConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.pf4j.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
@Api(description = "用户信息登录接口")
public class MonsterUserController {

    @Autowired
    private MonsterUserService monsterUserService;


    @ApiOperation(value = "用户登录", notes = "用户登录", produces = "application/json")
    @PostMapping(value = "/login")
    public Result<JSONObject> addMonsterModuleImg(@RequestBody UserInfo userInfo) {
        Result<JSONObject> result = new Result<>();
        try {
            if (StringUtils.isNullOrEmpty(userInfo.getCode())) {
                result.error500("个人信息不能为空！");
                return result;
            }
            monsterUserService.login(userInfo, result);
        } catch (Exception e) {
            e.printStackTrace();
            result.error500("操作失败");
        }
        return result;
    }


}
